#include <IRremote.h>
#define RELAY_PIN 2

int RECV_PIN = 3;
IRrecv irrecv(RECV_PIN);
decode_results results;
int ir_value;


void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(RELAY_PIN, OUTPUT);  
}


void loop() {
  if (irrecv.decode(&results)) {
    ir_value = results.value & 0b011111111111; //quitar bit toggle
    Serial.println(ir_value, HEX);
    switch (ir_value)
    {
    	case 1:digitalWrite(RELAY_PIN, HIGH);break;
    	case 2:digitalWrite(RELAY_PIN, LOW);break;
    }
    delay(100);
    irrecv.resume(); // Receive the next value
  }
}
